Skip to content

fix(claude-ops): resolve bash through PATH for the managed-scope enumeration - #5428

Merged
kyle-sexton merged 11 commits into
mainfrom
fix/5323-managed-scope-windows-bash
Sep 29, 2026
Merged

kyle-sexton merged 11 commits into
mainfrom
fix/5323-managed-scope-windows-bash

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Closes #5323

Summary

On windows-2025 the skill-visibility audit's two managed-scope tests failed with bash exited 1 sourcing the lib. enumerate_managed_scope ran a bare bash, and Windows CreateProcess searches System32 before PATH, so it launched the WSL relay bash.exe instead of Git Bash. The suite was therefore left out of test-windows.yml.

Fix

  • audit_skill_visibility.py: resolve bash through shutil.which before running the managed-scope enumeration (first commit).
  • test-windows.yml: restore the step "Test the skill-visibility audit on Windows" beside the markdown-format and cloud-bootstrap host-skip steps, and replace the "NOT here yet" comment entry with a description of the suite's cygpath probe.
  • test_audit_skill_visibility.py: the skipIf(bash is None) guard stays on test_managed_policy_false_outranks_local_true, the test that runs bash. The new bare-bash-name test never reaches a subprocess and has no guard.
  • claude-ops 0.66.1: the Fixed entry sits above main's 0.66.0 entry.

Verification

Path taken: fix, not the SKIP fallback. gh workflow run test-windows.yml --ref fix/5323-managed-scope-windows-bash (run 36621277399, windows-2025, head 6df01b1) is green. In the step log, BudgetArithmeticTest.test_managed_policy_outranks_local_through_the_vendored_lib and ReachabilityTest.test_managed_policy_false_outranks_local_true report ok, Ran 162 tests ... OK, and the --installed contract after unittest passes (ok: --installed collapsed 2 install records to 1 plugin (1 skill)). The commits after that run only move a test decorator and bump the version and changelog.

After merging origin/main (which released claude-ops 0.66.0): claude-ops bumped to 0.66.1 with a CHANGELOG entry above 0.66.0; scripts/check-changelog-parity.sh passes in --check, --check-bump origin/main, --check-order and --check-preserved origin/main modes; scripts/validate-plugins.sh passes; python3 -m unittest test_audit_skill_visibility runs 162 tests, OK; scripts/run-ruff.sh check on the scripts directory passes.

Related

Host-skip suites of #3683; earlier symptom in #992.

🤖 Generated with Claude Code

kyle-sexton and others added 7 commits September 29, 2026 15:39
…cope

On Windows a bare "bash" reaches the System32 WSL relay, which exits 1
with empty stderr. Resolve a bare name with shutil.which and report an
unreadable scope naming PATH when it is absent.

Refs #5323

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #5323

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…on fix

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The new bare-bash test was inserted between the skipIf(bash) decorator and
test_managed_policy_false_outranks_local_true, so the guard sat on the test
that never reaches bash and the test that runs bash lost it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main released claude-ops 0.64.1, so this fix moves to 0.64.2 with its
Fixed entry above main's 0.64.1 entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kyle-sexton
kyle-sexton marked this pull request as ready for review September 29, 2026 20:36
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-29T20:38:34.304541Z 96695a8 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@claude

claude Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 2m 36s —— View job


Reviewing PR #5428

  • Gather context (PR body, changed files, diff)
  • Read changed files
  • Analyze correctness / maintainability / test coverage
  • Post findings

Summary

The fix itself is sound: enumerate_managed_scope now resolves a bare bash name through
shutil.which before handing it to subprocess.run, which sidesteps Windows CreateProcess
preferring the System32 WSL relay over Git Bash on PATH. The branch is gated on
not os.path.dirname(bash), so callers that already pass an explicit path (e.g. the existing
"/nonexistent/bash-binary" test) still go straight to subprocess.run and keep exercising the
pre-existing OSError → "could not be run" path unchanged. The new
test_a_bare_bash_name_not_on_path_is_unreadable_naming_path test correctly needs no
skipIf guard, since shutil.which on a nonexistent name never reaches a subprocess. Version
bump and changelog ordering (0.64.3 above 0.64.2) are consistent.

One documentation-drift finding, on a line the diff doesn't touch so it can't carry an inline
comment:

.github/workflows/test-windows.yml — stale "two" count now covers three steps

# Two of the host-skip suites of #3683, named explicitly: each prints a
# SKIP line where its host probe fires, so a green step is only evidence
# once the log shows which of the two happened.

      # Two of the host-skip suites of #3683, named explicitly: each prints a
      # SKIP line where its host probe fires, so a green step is only evidence
      # once the log shows which of the two happened.

This comment introduces the markdown-format and cloud-bootstrap-plugins steps and was accurate
when only those two followed it. This PR inserts a third step right under it (Test the skill-visibility audit on Windows, line 279), but the comment wasn't updated to match. Per the
PR's own rewrite of the block above (lines 197–208), audit_skill_visibility is explicitly not
one of the two SKIP-line suites — it "prints no SKIP line," so a green step there means something
different (fixture rewrite succeeded) than a green step for the other two (their SKIP-fork did or
didn't fire). Left as-is, "named explicitly... which of the two happened" now misdescribes what a
green audit_skill_visibility step proves, in a file that otherwise goes to considerable lengths
to keep this exact distinction precise. Suggest updating the comment to name three suites and
carve out that the third's green/SKIP semantics differ (or move audit_skill_visibility's step
out from under this comment).

Fix this →

No correctness issues found in the Python fix or its test coverage.

@claude

claude Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 1m 54s —— View job


Security review — /review:security-review

  • Gather context (diff, changed files, current HEAD state)
  • Skip-gate check (PR open, has a security-relevant surface: subprocess bash resolution + CI workflow step)
  • Review each changed file for vulnerabilities
  • Report findings

Scope reviewed (HEAD 96695a8):

  • plugins/claude-ops/skills/audit-skill-visibility/scripts/audit_skill_visibility.py
  • plugins/claude-ops/skills/audit-skill-visibility/scripts/test_audit_skill_visibility.py
  • .github/workflows/test-windows.yml
  • plugins/claude-ops/.claude-plugin/plugin.json, plugins/claude-ops/CHANGELOG.md

Findings: none.

The core change in audit_skill_visibility.py lines 1162–1168 resolves a bare bash name through shutil.which before it's passed as argv[0] to subprocess.run([bash, "-c", MANAGED_SCOPE_SHIM, ...]). This is invoked with a list (not shell=True), so there's no shell-injection surface, and the bash parameter is never attacker- or user-supplied in production — the only caller (enumerate_managed_scope(managed_scope_lib_path()) at line 2822) uses the default "bash". The fix itself is a security improvement, not a regression: it makes the executable resolution follow standard PATH order instead of Windows CreateProcess's own search order (which checks the app directory and System32 before PATH), closing the accidental-WSL-relay-invocation gap rather than opening one.

The .github/workflows/test-windows.yml changes are comment rewording plus one new step that runs an existing, unmodified test script (audit_skill_visibility.test.sh) with a static path — no trigger, permissions:, or secrets handling was touched, so it's out of this lane's scope and not a zizmor-relevant finding either.

plugin.json / CHANGELOG.md changes are version/changelog bookkeeping with no security-relevant content.

No instruction-surface deletions (CLAUDE.md/AGENTS.md/rules/skill or agent bodies) are present in this diff, so the instruction-exception-register lens doesn't apply here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@claude

claude Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 2m 7s —— View job


Reviewing PR #5428

  • Gather context (PR body, changed files, diff via gh pr diff 5428)
  • Invoke /review:code-review for this PR
  • Review each changed file for correctness, maintainability, test coverage
  • Post findings

Findings

None. This is a re-review at the current head (446a3ca), which is a docs-only commit on top of 96695a8 (already reviewed by this lane). It exists specifically to fix the one finding raised on the prior review: the stale "Two of the host-skip suites... which of the two happened" comment in .github/workflows/test-windows.yml now reads "The host-skip suites... whether the probe fired or the cases ran," correctly generalized to cover the new third step (Test the skill-visibility audit on Windows, line 279) without the "which of the two" language that no longer applied. The accompanying block comment at lines 197–208 was also updated to name audit_skill_visibility as a third suite and correctly distinguish that it prints no SKIP line (a green step means the cygpath-rewritten --installed fixture resolved, not that a host probe branch was exercised) — I checked this claim against audit_skill_visibility.test.sh (host_path() at line 70 uses cygpath -m, and the script never echoes a SKIP line), and it holds.

Re-verified the core fix itself:

  • audit_skill_visibility.py:1162-1168 gates the shutil.which resolution on not os.path.dirname(bash), so the pre-existing "/nonexistent/bash-binary" test (line 1030 of the test file) still takes the unchanged subprocess.run → OSError → "could not be run" path, while the new bare-name test ("no-such-bash-xyz") resolves to None and reports "... is not on PATH" without touching a subprocess — matching the skipIf guard being absent from that new test but present on the one test that still shells out.
  • The only production caller (audit_skill_visibility.py:2822) uses the bash="bash" default, so it's the one path actually fixed by this change.
  • Version/changelog: 0.64.3 sits above 0.64.2 in both plugin.json and CHANGELOG.md, consistent with the PR's stated origin/main merge.

No correctness, maintainability, or test-coverage issues found on the changed lines. Test plan / CI run details in the PR description are author-claimed and not independently re-run by this review.
(branch)

@claude

claude Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 1m 10s —— View job


Security review — /review:security-review

  • Gather context (PR body, changed files, diff via gh pr diff)
  • Skip-gate check (PR open, has a security-relevant surface: subprocess bash resolution + CI workflow step)
  • Review each changed file for vulnerabilities
  • Check instruction-surface lens (workflow comment changes)
  • Post findings

Scope reviewed (HEAD 446a3ca):

  • plugins/claude-ops/skills/audit-skill-visibility/scripts/audit_skill_visibility.py
  • plugins/claude-ops/skills/audit-skill-visibility/scripts/test_audit_skill_visibility.py
  • .github/workflows/test-windows.yml
  • plugins/claude-ops/.claude-plugin/plugin.json, plugins/claude-ops/CHANGELOG.md

Findings: none.

The core fix in audit_skill_visibility.py lines 1162–1168 resolves a bare bash name through shutil.which before it is passed as argv[0] to subprocess.run([bash, "-c", MANAGED_SCOPE_SHIM, ...]). This is invoked with an argv list (not shell=True), so there is no shell-injection surface, and bash is never attacker- or user-supplied in production: the only call site (line 2822) uses the default "bash". The fix is a security improvement, not a regression — it makes executable resolution follow standard PATH order instead of Windows CreateProcess's own search order (which checks the app directory and System32, where the WSL relay bash.exe lives, before PATH).

The only change since the prior security review (at 96695a8) is a comment-only edit in test-windows.yml lines 272–274, updating the stale "two suites" text to cover the third (audit_skill_visibility) step this PR adds — pure prose, no triggers, permissions:, secrets handling, or action pins touched, and no removal/softening of a standing instruction under the instruction-exception-register (Gate 0) classes. The new workflow step itself runs an existing, unmodified test script at a static path, so it carries no injection surface and is out of this lane's scope (Actions hardening is zizmor's advisory lane; deferred, not re-reported here).

plugin.json / CHANGELOG.md changes are version/changelog bookkeeping with no security-relevant content.

…e-windows-bash

claude-ops is bumped to 0.64.4: main released 0.64.3, so the bash-resolution
entry moves above it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@claude

claude Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Claude encountered an error after 1s —— View job


I'll analyze this and get back to you.

@claude

claude Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Claude encountered an error after 0s —— View job


I'll analyze this and get back to you.

…e-windows-bash

Main released claude-ops 0.65.0; this branch's fix moves to 0.65.1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@claude

claude Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Claude encountered an error after 0s —— View job


I'll analyze this and get back to you.

@claude

claude Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Claude encountered an error after 0s —— View job


I'll analyze this and get back to you.

…e-windows-bash

Main released claude-ops 0.66.0; this branch's fix moves to 0.66.1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@claude

claude Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Claude encountered an error after 0s —— View job


I'll analyze this and get back to you.

@claude

claude Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Claude encountered an error after 0s —— View job


I'll analyze this and get back to you.

@kyle-sexton
kyle-sexton merged commit 90e1c8f into main Sep 29, 2026
3 checks passed
@kyle-sexton
kyle-sexton deleted the fix/5323-managed-scope-windows-bash branch September 29, 2026 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

claude-ops: audit-skill-visibility reads managed scope as unreadable on windows-2025 (bash exited 1 sourcing managed-scope.sh)

1 participant